home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 21 / Cream of the Crop 21 (Terry Blount) (October 1996).iso / utility / s48v13.zip / S48.DOC < prev   
Text File  |  1996-07-23  |  24KB  |  432 lines

  1.  
  2.                             ▄██████▄     ▄██▀ ▄██████▄
  3.                             ███  ███   ▄██▀   ███  ███
  4.                             ███▄▄▄▄  ▄██▀ ▄▄▄ ▀██▄▄██▀
  5.                              ▀▀▀▀███ ███▄▄███ ▄██▀▀██▄
  6.                             ███  ███ ▀▀▀▀▀███ ███  ███
  7.                             ▀██████▀      ███ ▀██████▀
  8.  
  9.  
  10.            A Full Screen Simulator for 8048 Compatible Microprocessors
  11.                                    Version 1.3
  12.  
  13.                                   William Luitje
  14.                                    23 July 1996 
  15.  
  16.  
  17.        ┌─────────────────────────────────────────────────────────────────┐
  18.        │▒▒▒ Background ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒│
  19.        └─────────────────────────────────────────────────────────────────┘
  20.  
  21.         I  wrote this simulator as part of my work on a consulting job  a 
  22.         few years ago.   There is still quite a lot of work one could  do 
  23.         to improve it, such as providing a way to manually change RAM and 
  24.         ports,   allowing  disassembly of any part  of  ROM,   simulating 
  25.         changes in inputs,  command files...  A LOT!  Still, I think it's 
  26.         useful,   as  is,   for learning the 8048   instruction  set  and 
  27.         debugging small programs.   I hope it's useful to you; if you use 
  28.         it,   please  see  the registration section at the  end  of  this 
  29.         document (relax, no money is involved). 
  30.  
  31.         With  the  work I mentioned above and some features  specifically 
  32.         for  an educational environment,  this program would make a great 
  33.         tool   for  teaching  microprocessor  programming.     Commercial 
  34.         programs like this cost from US$200 to $300.  If I make an educa-
  35.         tional version of S48,  I  envision a site licensing  arrangement 
  36.         which would cost a very modest amount per student.  If you are an 
  37.         instructor or administrator and are interested in pursuing  this, 
  38.         contact  me at the address given at the end of this document even 
  39.         if you use a different micro in your course. 
  40.  
  41.        ┌─────────────────────────────────────────────────────────────────┐
  42.        │▒▒▒ Introduction ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒│
  43.        └─────────────────────────────────────────────────────────────────┘
  44.  
  45.         S48   simulates the instruction set and some of the hardware  for 
  46.         the 8048,  8049,  8050, 8021, 8022  microprocessors originated by 
  47.         Intel and now widely second-sourced.  The simulator handles these 
  48.         hardware parameters: 
  49.  
  50.         ■ 4096 bytes of ROM
  51.         ■ 128 bytes of internal RAM
  52.         ■ 256 bytes of external RAM
  53.         ■ 7 I/O ports
  54.         ■ one 8 bit timer
  55.  
  56.         The  hardware  registers  and  flags  and  RAM  are  continuously 
  57.         displayed  on  screen  and  are updated as  each  instruction  is 
  58.         executed.  There is a disassembly window showing the instructions 
  59.         as they are executed.   You can trace through instructions one at 
  60.         a time or execute them continuously until a breakpoint is reached 
  61.         or you stop the program manually. 
  62.         
  63.         The  hardware requirements to run S48  are quite simple;   you'll 
  64.         need  a  PC  with a monochrome,  Hercules,  CGA,   EGA,   or  VGA 
  65.         compatible  video card (the program does direct screen writes  so 
  66.         you'll  see snow using CGA).   A  color display is  not  strictly 
  67.         necessary, but is certainly helpful in reading the screen easily.  
  68.         Obviously,  the faster your CPU,  the faster the simulation  will 
  69.         run.  A 4.77 MHz PC is adequate for small programs.  The software 
  70.         requirements  are even simpler:  you'll need some version of DOS, 
  71.         S48 and an 8048 program to simulate.  
  72.          
  73.        ┌─────────────────────────────────────────────────────────────────┐
  74.        │▒▒▒ Sample Program ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒│
  75.        └─────────────────────────────────────────────────────────────────┘
  76.  
  77.         I've included a very simple sample program for you to play  with, 
  78.         called demo.bin.  demo.asm is the source file and implements a 16 
  79.         bit  counter in software.   There is an interrupt service routine 
  80.         which  captures  the low byte of that counter and  stores  it  in 
  81.         consecutive  locations  in  external RAM when  the  interrupt  is 
  82.         invoked.  The timer interrupt service routine increments an 8 bit 
  83.         counter  when the timer overflows.  It's short enough that I  can 
  84.         reproduce  its  assembly listing here: 
  85.  
  86.                                      .org   0
  87.            0000 00                   nop    
  88.            0001 04 09                jmp    start
  89.            0003                      .org   3
  90.            0003 00                   nop
  91.            0004 00                   nop
  92.            0005 04 1B                jmp    intsvc
  93.            0007                      .org   7
  94.            0007 04 21                jmp    tmrsvc
  95.            0009             ; Initialization
  96.            0009 27          start    clr    a
  97.            000A A8                   mov    r0,a
  98.            000B A9                   mov    r1,a
  99.            000C AB                   mov    r3,a
  100.            000D 62                   mov    t,a
  101.            000E B8 18                mov    r0,#24
  102.            0010 A0                   mov    @r0,a
  103.            0011 25                   en     tcnti
  104.            0012 55                   strt   t
  105.            0013 05                   en     i
  106.            0014             ; Main Loop
  107.            0014 18          loop     inc    r0
  108.            0015 F8                   mov    a,r0
  109.            0016 96 14                jnz    loop
  110.            0018 19                   inc    r1
  111.            0019 04 14                jmp    loop
  112.            001B             ; External Interrupt Service Routine
  113.            001B F8          intsvc   mov    a,r0
  114.            001C D5                   sel    rb1
  115.            001D 90                   movx   @r0,a
  116.            001E 18                   inc    r0
  117.            001F C5                   sel    rb0
  118.            0020 93                   retr
  119.            0021             ; Timer Overflow Interrupt Service Routine
  120.            0021 1B          tmrsvc   inc    r3
  121.            0022 93                   retr
  122.            0023                      .end
  123.  
  124.         You'll also need an understanding of the 8048 instruction set and 
  125.         architecture.  You won't find much help in this document. 
  126.  
  127.        ┌─────────────────────────────────────────────────────────────────┐
  128.        │▒▒▒ Tutorial ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒│
  129.        └─────────────────────────────────────────────────────────────────┘
  130.  
  131.         The 8048 program to be executed can be in either Intel hex format 
  132.         or binary, like you would use to program an EPROM.  The simulator 
  133.         tries  to  read  the file in hex format first and if  that  fails 
  134.         assumes that the file is binary.   To invoke the simulator,  just 
  135.         give the name of the program file as an argument, e.g.: 
  136.  
  137.         s48 demo.bin 
  138.  
  139.         Take  a  minute to familiarize yourself with the  layout  of  the 
  140.         screen: 
  141.  
  142.  ┌────────────────────────────────────────────────────────────────────────────┐
  143.  │Cmd:                                                                        │
  144.  │ 35 bytes read from demo.bin                                                │
  145.  │┌─PC┐ ┌A─┐┌PSW┬CY┬AC┬F0┬F1┬RB┬STK┐TIE┬TS┬TF┬TM┐                             │
  146.  │└000┘ └  ┘└─08┴─ ┴─ ┴─0┴─0┴─0┴──0┘└─0┴─0┴00┴  ┘                             │
  147.  │ ┌MB┐ ┌Bus┐┌P1┬P2┬P3┬P4┬P5┬P6┬P7┐ ┌T0┬T1┬II┬IE┐                             │
  148.  │ └─0┘ └─  ┘└  ┴  ┴  ┴  ┴  ┴  ┴  ┘ └─ ┴─ ┴─ ┴─ ┘                             │
  149.  │    ╔═00══10══20══30══40══50══60══70═══╗          ▒000▒00▒▒▒▒NOP▒▒▒▒▒▒▒     │
  150.  │ 00 ║ ░░                               ║ 08        001 04 06 JMP  006       │
  151.  │ 01 ║ ░░                               ║ 09        003 00    NOP            │
  152.  │ 02 ║ ░░